//
//  TestObject.m
//  Box2DProject
//
//  Created by Thi Huynh on 9/12/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "TestObject.h"

@implementation TestObject

- (id)initPolygonWith:(b2World *)world fileName:(NSString *)name
{
    _vertexCount = 7;
    _fileName = IMG_OBJECT_WATERMELON;
    b2Vec2 vertices[] = {
        b2Vec2(5.0/PTM_RATIO,15.0/PTM_RATIO),
        b2Vec2(18.0/PTM_RATIO,7.0/PTM_RATIO),
        b2Vec2(32.0/PTM_RATIO,5.0/PTM_RATIO),
        b2Vec2(48.0/PTM_RATIO,7.0/PTM_RATIO),
        b2Vec2(60.0/PTM_RATIO,14.0/PTM_RATIO),
        b2Vec2(34.0/PTM_RATIO,59.0/PTM_RATIO),
        b2Vec2(28.0/PTM_RATIO,59.0/PTM_RATIO)
    };
    
    _shapeVertices = vertices;
    CGSize screen = [[CCDirector sharedDirector] winSize];

    b2Body *body = [self createBodyWith:world position:b2Vec2(screen.width/2/PTM_RATIO,screen.height/2/PTM_RATIO) rotation:0 vertices:_shapeVertices vertexCount:_vertexCount density:5.0 friction:0.2 restitution:0.2];

    if ((self = [super initWithFileName:_fileName body:body destroyed:NO]))
    {
        
    }
    return self;

}

- (id)initPolygonWith:(b2World *)world fileName:(NSString *)name andPos:(CGPoint )pos
{
    _vertexCount = 8;
    _fileName = IMG_OBJECT_ROCK;
    
    b2Vec2 vertices[] = {
        b2Vec2(46/PTM_RATIO,125/PTM_RATIO),
        b2Vec2(12/PTM_RATIO,106/PTM_RATIO),
        b2Vec2(1/PTM_RATIO,67/PTM_RATIO),
        b2Vec2(1/PTM_RATIO,21/PTM_RATIO),
        b2Vec2(22/PTM_RATIO,3/PTM_RATIO),
        b2Vec2(86/PTM_RATIO,3/PTM_RATIO),
        b2Vec2(101/PTM_RATIO,26/PTM_RATIO),
        b2Vec2(100/PTM_RATIO,78/PTM_RATIO)
    };
    /*b2Vec2 vertices[] = {
        b2Vec2(2/PTM_RATIO,2/PTM_RATIO),
        b2Vec2(2/PTM_RATIO,121/PTM_RATIO),
        b2Vec2(100/PTM_RATIO,121/PTM_RATIO),
        b2Vec2(100/PTM_RATIO,2/PTM_RATIO),
    };*/
    _shapeVertices = vertices;
    
    b2Body *body = [self createBodyWith:world position:b2Vec2(pos.x/PTM_RATIO,pos.y/PTM_RATIO) rotation:0 vertices:_shapeVertices vertexCount:_vertexCount density:5.0 friction:0.2 restitution:0.2];
    
    if ((self = [super initWithFileName:_fileName body:body destroyed:NO]))
    {
        
    }
    return self;
}

@end
